﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BBPA.Admin.SYS.Express
{
    public partial class Form : FormPage
    {
        BLL.Express bll = new BLL.Express();
        Model.Express model = new Model.Express();
        protected void Page_Load(object sender, EventArgs e) { }
        /// <summary>
        /// 初始化本页Model
        /// </summary>
        public override void Page_Load_DefaultModel() { model = bll.GetModel(Master.id);}
        /// <summary>
        /// 初始化表单
        /// </summary>
        public override void Form_Default()
        {
        }
        /// <summary>
        /// 绑定表单数据【修改时用】
        /// </summary>
        public override void Form_Bind()
        {
            tb_Name.Text = model.Name;

            tb_Tel.Text = model.Tel;
            tb_Mobile.Text = model.Mobile;
            tb_Description.Text = model.Description;
        }
        /// <summary>
        /// 提交
        /// </summary>
        public override void Form_Submit()
        {
            string Name = PageValidate.SqlTextClear(DataTypePlus.requestString(tb_Name.Text));
            string Tel = PageValidate.SqlTextClear(DataTypePlus.requestString(tb_Tel.Text));
            string Mobile = PageValidate.SqlTextClear(DataTypePlus.requestString(tb_Mobile.Text));
            string Description =tb_Description.Text;

            if (
                Master.noEmpty(Name, "[物流名称]必须填写") &&
                Master.noChongfu("Name='" + Name + "'", "[物流名称]重复")
                )
            {
                model.Name = Name;
                model.Tel = Tel;
                model.Mobile = Mobile;
                model.Description = Description;
                if (Master.formState == EnumHelper.FormState.add)Master.id= bll.Add(model);
                else bll.Update(model);
                BLL.User_Operate_Log.Add(Security.GetCurrentUserID(), EnumHelper.TableName.Goods_BuyPrice_Log, Master.id, Master.formState == EnumHelper.FormState.add ? EnumHelper.OperateType.Add : EnumHelper.OperateType.Update, "");
                Master.SubmitOK();

            }
        }
    }
}